﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Customer.Bussiness_Service;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ServiceCore;

namespace Customer.Areas.MiniProgram.Controllers
{
    [ApiController, Area("MiniProgram"), Route("/MiniProgram/[action]")]
    public class ApiController : ControllerBase
    {
        private readonly Irk_mini_service _service;
        private readonly IToole_DI _tool;
        public ApiController(Irk_mini_service service, IToole_DI tool)
        {
            _service = service;
            _tool = tool;
        } 
        /// <summary>
        /// 登录凭证校验。
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel code2Session(string code)
        {
            var result = _service.code2Session(code);
            return result;
        }

        /// <summary>
        /// 用户支付完成后，获取该用户的 UnionId 调用前需要用户完成支付，且在支付后的五分钟内有效
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel getPaidUnionId(string openid)
        {
            var result = _service.getPaidUnionId(openid);
            return result;
        }
    }
}